#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
//http://oj33.cn/contest.php?cid=1075
char board[21][21];
int x1, y11;
int x[4] = { 0,0,1,-1 }, y[4] = { 1,-1,0,0 };
bool f[21][21]={};
int sum = 0;
	int w, h;
void dfs(int a, int b)
{
	f[a][b] = 1;
	sum++;
	for (int i = 0; i < 4; i++)
	if (!f[a + x[i]][b + y[i]] && a + x[i] >= 0 && a + x[i] < h && b + y[i] >= 0 && b + y[i] < w&& board[a + x[i]][b + y[i]]=='.')
			dfs(a + x[i], b+y[i]);
}
int main()
{


	while(true){
		
	cin >> w >> h;
	if (w == 0 && h == 0)return 0;
	for (int i = 0; i <h ;i++)
	{
		for (int j =0; j <w; j++)
		{
			cin >> board[i][j];
			f[i][j] = 0;
			if (board[i][j] == '@')
			{
				x1 = i; y11 = j;
			}
			
		}
	}
	sum = 0;
	dfs(x1, y11);
	cout << sum << endl;
	}
}/*
#include<iostream>
using namespace std;
int w, h;
int startI, startJ;
char room[25][25];
int cnt;
int sx[4] = { 0,0,-1,1 };
int sy[4] = { -1,1,0,0 };
void dfs(int x, int y) {
	cnt++;
	room[x][y] = '#';
	for (int i = 0; i < 4; i++) {
		int nx = x + sx[i];
		int ny = y + sy[i];
		if (nx >= 0 && nx < h && ny >= 0 && ny < w && room[nx][ny] == '.') {
			dfs(nx, ny);
		}
	}
}
int main() {
	while (1) {
		cin >> w >> h;
		if (w == 0 && h == 0) break;
		cnt = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> room[i][j];
				if (room[i][j] == '@') {
					startI = i;
					startJ = j;
				}
			}
		}
		dfs(startI, startJ);
		cout << cnt << endl;
	}
	return 0;
}*/
